package cn.com.bluemoon.daps.common.validation.sql;

import com.alibaba.druid.DbType;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @author Jarod.Kong
 * @date 2021/1/22 14:49
 */
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@Documented
@Constraint(validatedBy = NoSqlKeywordValidator.class)
public @interface NoSqlKeyword {
    DbType dbtype() default DbType.mysql;

    String name() default "";

    String message() default "{name}不可为{dbtype}关键字";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * Defines several {@link NoSqlKeyword} annotations on the same element.
     *
     * @see NoSqlKeyword
     */
    @Target({FIELD})
    @Retention(RUNTIME)
    @Documented
    @interface List {

        NoSqlKeyword[] value();
    }
}
